<?php

/**
 * This is the model class for table "pengalihan".
 *
 * The followings are the available columns in table 'pengalihan':
 * @property integer $kode_png
 * @property string $no_op
 * @property string $kode_jns
 * @property string $nama_pmk
 * @property string $alamat_pmk
 * @property string $nik_pmk
 * @property string $nama_pnm
 * @property string $alamat_pnm
 * @property string $nik_pnm
 * @property string $rt_pnm
 * @property string $rw_pnm
 * @property string $kel_pnm
 * @property string $kec_pnm
 * @property string $kab_pnm
 * @property string $kodepos_pnm
 * @property double $lt_awal
 * @property double $tnjop_awal
 * @property double $nt_awal
 * @property double $ltb_awal
 * @property double $njoptb_awal
 * @property double $ntb_awal
 * @property double $tonil_awal
 * @property double $jml_pngtnh
 * @property double $jml_pngbng
 * @property double $harga_pas
 * @property double $lt_akhir
 * @property double $tnjop_akhir
 * @property double $nt_akhir
 * @property double $ltb_akhir
 * @property double $njoptb_akhir
 * @property double $ntb_akhir
 * @property double $tonil_akhir
 * @property double $hrgpas_akhir
 * @property string $nosert_lama
 * @property string $nosert_baru
 * @property string $tgl_prs
 * @property string $nop_baru
 * @property double $pajak_bphtb
 * @property string $kode_user
 *
 * The followings are the available model relations:
 * @property Users $kodeUser
 * @property ObjekPajak $noOp
 * @property JenisPrh $kodeJns
 */
class Pengalihan extends CActiveRecord
{
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'pengalihan';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('kode_user', 'required'),
			array('lt_awal, tnjop_awal, nt_awal, ltb_awal, njoptb_awal, ntb_awal, tonil_awal, jml_pngtnh, jml_pngbng, harga_pas, lt_akhir, tnjop_akhir, nt_akhir, ltb_akhir, njoptb_akhir, ntb_akhir, tonil_akhir, hrgpas_akhir, pajak_bphtb', 'numerical'),
			array('no_op, nop_baru', 'length', 'max'=>18),
			array('kode_jns', 'length', 'max'=>2),
			array('nama_pmk, nama_pnm', 'length', 'max'=>35),
			array('alamat_pmk, alamat_pnm, nosert_lama, nosert_baru', 'length', 'max'=>50),
			array('nik_pmk, nik_pnm', 'length', 'max'=>16),
			array('rt_pnm, rw_pnm', 'length', 'max'=>3),
			array('kel_pnm, kec_pnm, kab_pnm', 'length', 'max'=>25),
			array('kodepos_pnm, kode_user', 'length', 'max'=>8),
			array('tgl_prs', 'safe'),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('kode_png, no_op, kode_jns, nama_pmk, alamat_pmk, nik_pmk, nama_pnm, alamat_pnm, nik_pnm, rt_pnm, rw_pnm, kel_pnm, kec_pnm, kab_pnm, kodepos_pnm, lt_awal, tnjop_awal, nt_awal, ltb_awal, njoptb_awal, ntb_awal, tonil_awal, jml_pngtnh, jml_pngbng, harga_pas, lt_akhir, tnjop_akhir, nt_akhir, ltb_akhir, njoptb_akhir, ntb_akhir, tonil_akhir, hrgpas_akhir, nosert_lama, nosert_baru, tgl_prs, nop_baru, pajak_bphtb, kode_user', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'kodeUser' => array(self::BELONGS_TO, 'Users', 'kode_user'),
			'noOp' => array(self::BELONGS_TO, 'ObjekPajak', 'no_op'),
			'kodeJns' => array(self::BELONGS_TO, 'JenisPrh', 'kode_jns'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'kode_png' => 'Kode Png',
			'no_op' => 'No Op',
			'kode_jns' => 'Kode Jns',
			'nama_pmk' => 'Nama Pmk',
			'alamat_pmk' => 'Alamat Pmk',
			'nik_pmk' => 'Nik Pmk',
			'nama_pnm' => 'Nama Pnm',
			'alamat_pnm' => 'Alamat Pnm',
			'nik_pnm' => 'Nik Pnm',
			'rt_pnm' => 'Rt Pnm',
			'rw_pnm' => 'Rw Pnm',
			'kel_pnm' => 'Kel Pnm',
			'kec_pnm' => 'Kec Pnm',
			'kab_pnm' => 'Kab Pnm',
			'kodepos_pnm' => 'Kodepos Pnm',
			'lt_awal' => 'Lt Awal',
			'tnjop_awal' => 'Tnjop Awal',
			'nt_awal' => 'Nt Awal',
			'ltb_awal' => 'Ltb Awal',
			'njoptb_awal' => 'Njoptb Awal',
			'ntb_awal' => 'Ntb Awal',
			'tonil_awal' => 'Tonil Awal',
			'jml_pngtnh' => 'Jml Pngtnh',
			'jml_pngbng' => 'Jml Pngbng',
			'harga_pas' => 'Harga Pas',
			'lt_akhir' => 'Lt Akhir',
			'tnjop_akhir' => 'Tnjop Akhir',
			'nt_akhir' => 'Nt Akhir',
			'ltb_akhir' => 'Ltb Akhir',
			'njoptb_akhir' => 'Njoptb Akhir',
			'ntb_akhir' => 'Ntb Akhir',
			'tonil_akhir' => 'Tonil Akhir',
			'hrgpas_akhir' => 'Hrgpas Akhir',
			'nosert_lama' => 'Nosert Lama',
			'nosert_baru' => 'Nosert Baru',
			'tgl_prs' => 'Tgl Prs',
			'nop_baru' => 'Nop Baru',
			'pajak_bphtb' => 'Pajak Bphtb',
			'kode_user' => 'Kode User',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 *
	 * Typical usecase:
	 * - Initialize the model fields with values from filter form.
	 * - Execute this method to get CActiveDataProvider instance which will filter
	 * models according to data in model fields.
	 * - Pass data provider to CGridView, CListView or any similar widget.
	 *
	 * @return CActiveDataProvider the data provider that can return the models
	 * based on the search/filter conditions.
	 */
	public function search()
	{
		// @todo Please modify the following code to remove attributes that should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('kode_png',$this->kode_png);
		$criteria->compare('no_op',$this->no_op,true);
		$criteria->compare('kode_jns',$this->kode_jns,true);
		$criteria->compare('nama_pmk',$this->nama_pmk,true);
		$criteria->compare('alamat_pmk',$this->alamat_pmk,true);
		$criteria->compare('nik_pmk',$this->nik_pmk,true);
		$criteria->compare('nama_pnm',$this->nama_pnm,true);
		$criteria->compare('alamat_pnm',$this->alamat_pnm,true);
		$criteria->compare('nik_pnm',$this->nik_pnm,true);
		$criteria->compare('rt_pnm',$this->rt_pnm,true);
		$criteria->compare('rw_pnm',$this->rw_pnm,true);
		$criteria->compare('kel_pnm',$this->kel_pnm,true);
		$criteria->compare('kec_pnm',$this->kec_pnm,true);
		$criteria->compare('kab_pnm',$this->kab_pnm,true);
		$criteria->compare('kodepos_pnm',$this->kodepos_pnm,true);
		$criteria->compare('lt_awal',$this->lt_awal);
		$criteria->compare('tnjop_awal',$this->tnjop_awal);
		$criteria->compare('nt_awal',$this->nt_awal);
		$criteria->compare('ltb_awal',$this->ltb_awal);
		$criteria->compare('njoptb_awal',$this->njoptb_awal);
		$criteria->compare('ntb_awal',$this->ntb_awal);
		$criteria->compare('tonil_awal',$this->tonil_awal);
		$criteria->compare('jml_pngtnh',$this->jml_pngtnh);
		$criteria->compare('jml_pngbng',$this->jml_pngbng);
		$criteria->compare('harga_pas',$this->harga_pas);
		$criteria->compare('lt_akhir',$this->lt_akhir);
		$criteria->compare('tnjop_akhir',$this->tnjop_akhir);
		$criteria->compare('nt_akhir',$this->nt_akhir);
		$criteria->compare('ltb_akhir',$this->ltb_akhir);
		$criteria->compare('njoptb_akhir',$this->njoptb_akhir);
		$criteria->compare('ntb_akhir',$this->ntb_akhir);
		$criteria->compare('tonil_akhir',$this->tonil_akhir);
		$criteria->compare('hrgpas_akhir',$this->hrgpas_akhir);
		$criteria->compare('nosert_lama',$this->nosert_lama,true);
		$criteria->compare('nosert_baru',$this->nosert_baru,true);
		$criteria->compare('tgl_prs',$this->tgl_prs,true);
		$criteria->compare('nop_baru',$this->nop_baru,true);
		$criteria->compare('pajak_bphtb',$this->pajak_bphtb);
		$criteria->compare('kode_user',$this->kode_user,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}

	/**
	 * Returns the static model of the specified AR class.
	 * Please note that you should have this exact method in all your CActiveRecord descendants!
	 * @param string $className active record class name.
	 * @return Pengalihan the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}
